#include <stdio.h>
#include <math.h>
float fsin(float x){
    return sin(x);
}
float fcos(float x){
    return cos(x);
}
float fexc(float x){
    return exp(x);
}
float integral(float (*p)(float), float a, float b, int n){
    float h, sum=0;
    h=(b-a)/n;
    for(int i=0; i<n; i++){
        sum+=p(a+i*h);
    }
    return sum*h;
}
int main(){
    float a1,b1,a2,b2,a3,b3,c;
    int n=20;
    printf("input a1,b1:");
    scanf("%f %f",&a1,&b1);
    printf("input a2, b2:");
    scanf("%f %f", &a2, &b2);
    printf("input a3, b3:");
    scanf("%f %f", &a3, &b3);
    c=integral(fsin,a1,b1,n);
    printf("The integral of sin(x) is: %f\n",c);
    c=integral(fcos, a2, b2, n);
    printf("The integral of cos(x) is: %f\n", c);
    c=integral(fexc, a3, b3, n);
    printf("The integral of exp(x) is: %f\n", c);
    return 0;

}